package com.cskaoyan.shopping.service.remote;

import com.cskaoyan.mall.api.SearchProductService;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.mall.dto.AllItemResponse;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: csmall-practice
 * @description:
 * @author: Lexis
 * @create: 2022-05-26 19:41
 **/

@RestController
public class SearchProductServiceImpl implements SearchProductService {

    @Autowired
    IProductService productService;

    @GetMapping("/rpc/items")
    @Override
    public AllItemResponse getAllProductItem() {
        AllItemResponse response = productService.getAllItems();
        if (response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())) {
            return response;
        }
        return null;
    }
}
